package com.cskaoyan.market.util;

import java.io.InputStream;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import com.cskaoyan.market.service.impl.MarketAdminServiceImpl;

/**
 * @ClassName MyBatisUtil
 * @Description: TODO
 * @Author 远志 zhangsong@cskaoyan.onaliyun.com
 * @Date 2023/3/17 14:51
 * @Version V1.0
 **/
public class MyBatisUtil {

    private static SqlSessionFactory factory;

    static {
        InputStream inputStream = MarketAdminServiceImpl.class.getClassLoader().getResourceAsStream("mybatis.xml");
        factory = new SqlSessionFactoryBuilder().build(inputStream);
    }

    public static SqlSession getSession(){
        return factory.openSession();
    }
}
